package com.avic.process.utils;

import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.teamcenter.rac.util.Utilities;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.SwingConstants;

@SuppressWarnings("serial")
public class MessageBox extends JDialog implements ActionListener
{
	private JButton button;
	private JLabel label;
	public MessageBox(Window owner) 
	{
		super(owner);
		setTitle("\u63D0\u793A");
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setIconImage(Toolkit.getDefaultToolkit().getImage(MessageBox.class.getResource("/com/kostech/process/utils/images/teamcenter16.png")));
		setSize(326, 107);
		setResizable(false);
		setModal(true);
		setLocationRelativeTo(owner);
		getContentPane().setLayout(null);
		
		button = new JButton("\u786E  \u5B9A");
		button.setBounds(115, 45, 90, 25);
		getContentPane().add(button);
		button.addActionListener(this);
		
		JPanel panel = new JPanel();
		panel.setBounds(10, 10, 300, 25);
		getContentPane().add(panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		label = new JLabel("");
		label.setHorizontalAlignment(SwingConstants.CENTER);
		panel.add(label, BorderLayout.CENTER);
		
	}
	@Override
	public void actionPerformed(ActionEvent e)
	{
		dispose();
	}

	
	public static void show(String text)
	{
		Window owner = Utilities.getCurrentWindow();
		MessageBox msg = new MessageBox(owner);
		msg.label.setText(text);
		msg.setVisible(true);
	}
}
